package com.richie696.rabbit.order.enums;

import java.util.Arrays;

public enum OrderStatus {

    CREATE(1, "等待支付"),
    CLOSED(8, "订单已关闭"),
    FINISHED(9, "支付完成");

    private final int id;
    private final String name;
    OrderStatus(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static OrderStatus valueOf(int id) {
        return Arrays.stream(values()).filter(o -> o.id == id).findFirst().orElseThrow(IllegalArgumentException::new);
    }

}
